//
//  OrderPayViewController.m
//  RainbowFM
//
//  Created by Kratos on 14/12/18.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "OrderPayViewController.h"
#import "OrderModel.h"
#import "PayViewController.h"

@interface OrderPayViewController ()

@property (weak, nonatomic) IBOutlet UILabel *orderNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *payPriceLabel;
@property (nonatomic , strong) IBOutlet UITextView *infoTextView;
@property (nonatomic , strong) IBOutlet UIButton *payButton;
@property (weak, nonatomic) IBOutlet UIButton *checkButton;
@end

@implementation OrderPayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.orderNumLabel.text = _orderId;
    self.payPriceLabel.text = _RMB(_payPrice);
    // Do any additional setup after loading the view.
}
- (IBAction)checkAction:(UIButton *)sender {
    sender.selected = !sender.selected;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)payAction:(id)sender {
    if (!_checkButton.selected) {
        [SVProgressHUD showErrorWithStatus:@"请选择支付方式"];
        return;
    }
    
    [[OrderModel sharedModel] paymentWithOrderID:_orderId payType:@"alipay" result:^(BOOL success, NSString *payURL, NSString *msg) {
        if (success) {
            PayViewController *payView = [self.storyboard instantiateViewControllerWithIdentifier:@"PayViewController"];
            payView.payURL = payURL;
            [self.navigationController pushViewController:payView animated:YES];
        }
    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
